Skip to main content

Shipping label

In this section, you will find the explanation of how to create a shipping label.

Shipping label request

To get a shipping label, you need to send a GET request to the endpoint /api/Carriers/[CARRIER_ID]/shippingLabel with the request body. The path will be different depending on the output format you want. Here are the different paths:

Output formatPath
ZPL/api/Carriers/[CARRIER_ID]/shippingLabel/zpl
PDF/api/Carriers/[CARRIER_ID]/shippingLabel/pdf

The request body should contain the following fields:

FieldTypeFormatDescription
trackingNumberREQUIREDstringThe tracking number of the shipment

ZPL

Here's an example in JavaScript of sending a request to create a shipping label in ZPL format:

curl --location --globoff --request GET 'https://alphadev-api.peddler.com/api/Carriers/[CARRIER_ID]/shippingLabel/zpl' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer RRMg2ef7jspI7Ze0NG6DjV6P8CVHJpr7' \
--data '{
"trackingNumber": "P195214835232769147"
}'

PDF

Here's an example in JavaScript of sending a request to create a shipping label in PDF format:

curl --location --globoff --request GET 'https://alphadev-api.peddler.com/api/Carriers/[CARRIER_ID]/shippingLabel/pdf' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer RRMg2ef7jspI7Ze0NG6DjV6P8CVHJpr7' \
--data '{
"trackingNumber": "P195214835232769147"
}'

Shipping label response

Depending on the output format, the response will be different.

ZPL

If the output format is ZPL, the response will be a string containing the ZPL code.

ZPL response 200 OK
HTTP/1.1 200 OK
Content-Type: text/plain

^XA^FO50,50^A0N,50,50^FD123456789^FS^XZ

ZPL response 404 Not Found
HTTP/1.1 404 Not Found
Content-Type: application/json
Content-Length: 12345

{
"error": {
"statusCode": 404,
"name": "tracking-number-not-found",
"message": "TRACKING NUMBER NOT FOUND"
}
}

PDF

If the output format is PDF, the response will be a base64 encoded string containing the PDF file.

PDF response 200 OK
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 12345
Content-Disposition: attachment; filename="XXXXXX1.pdf"
Content-Transfer-Encoding: base64
PDF response 404 Not Found
HTTP/1.1 404 Not Found
Content-Type: application/pdf

{
"error": {
"statusCode": 404,
"name": "tracking-number-not-found",
"message": "TRACKING NUMBER NOT FOUND"
}
}